# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：     __init__.py
   Description :   TODO
   Author :       RedReins
   date：          2021/6/1
-------------------------------------------------
"""

'''
1.设置Flask框架名称
2.设置数据库参数
3.设置项目缓存
4.设置密钥
5.设置数据库连接
6.设置缓存机制

flask_sqlalchemy:Flask框架连接数据库
'''

import os
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_redis import FlaskRedis

# 项目作者
__author__ = "RedReins"

# 1.设置项目名称
app = Flask(__name__)

# 2.数据库的连接设置
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://red_reins1:DHAY9!7Eqd6Lg95@mypolar.rwlb.rds.aliyuncs.com:3306/mjtt'

app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True

# 3.设置项目缓存
app.config['REDIS_URL'] = 'redis://127.0.0.1:6379'

app.config['SECRET_KEY'] = 'zt_movie'

# 上传目录
app.config['UP_DIR'] = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'static/uploads/')
app.config['FC_DIR'] = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'static/uploads/users/')

# 4.设置DEBUG模式
app.debug = False

# 5.数据库连接
db = SQLAlchemy(app)

# 6.设置缓存
rd = FlaskRedis(app)

# 7.注册蓝图
from app.admin import admin as admin_blueprint

app.register_blueprint(admin_blueprint, url_prefix='/')
